/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.foxline.converter;

import br.com.foxline.model.Lot;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

/**
 *
 * @author roniere
 */
@FacesConverter(value = "lotconverter")
public class LotConverter implements Converter{

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        Lot lot = new Lot();
        System.out.println("value " + value);
        if(value != null  && !value.equals("")){
            lot.setId(Long.valueOf(value));
        }
        return lot;
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
           
        if(value != null && !value.equals("")){
            Lot lot = (Lot) value;
            return lot.getId()+"";
        }
        return "";
    }
    
    
    
}
